package math2;

/**
 * a unit function implemented as singleton to save space and consistent
 * 
 * @author hbui
 * 
 */
public class UnitFunctionRnToR extends FunctionRnToR {

	private static UnitFunctionRnToR instance = new UnitFunctionRnToR();

	private UnitFunctionRnToR() {
	}

	/**
	 * Get the instance of UnitFunctionRnToR singleton
	 * 
	 * @return the Singleton instance
	 */
	public static UnitFunctionRnToR getInstance() {
		return instance;
	}

	@Override
	public double[] gradientAt(double... x) {
		return new double[x.length];
	}

	@Override
	public double valueAt(double... x) {
		return 1.0;
	}
}
